<template>
	<view>
		<view class="node-wrap y-f" v-if="nodeConfig.type!=4">
			<view class="node-wrap-box"
				:class="(nodeConfig.type==0?'start-node ':'')+(isTried&&nodeConfig.error?'active error':'')">
				<view>
					<view class="title"
						:style="'background: rgb('+ ['87, 106, 149','255, 148, 62','50, 150, 250'][nodeConfig.type] +');'">

						<text v-if="nodeConfig.type==0">{{nodeConfig.nodeName}}</text>
						<input type="text" class="ant-input editable-title-input" v-if="nodeConfig.type!=0&&isInput"
							v-model="nodeConfig.nodeName" focus :placeholder="placeholderList[nodeConfig.type]"
							@blur="isInput=false">
						<text class="editable-title" @click="clickEvent()"
							v-if="nodeConfig.type!=0&&!isInput">{{nodeConfig.nodeName}}</text>
						<text class="anticon anticon-close close" v-if="nodeConfig.type!=0" @click="delNode()"></text>
					</view>
					<view class="content" @click="setPerson">
						<!-- 发起人 -->
						<view class="text" v-if="nodeConfig.type==0">
							{{arrToStr(flowPermission)}}
						</view>
						<!-- 审批人 -->
						<view class="text" v-if="nodeConfig.type==1">
							<text class="placeholder"
								v-if="!setApproverStr(nodeConfig)">请选择{{placeholderList[nodeConfig.type]}}</text>
							{{setApproverStr(nodeConfig)}}
						</view>
						<!-- 抄送人 -->
						<view class="text" v-if="nodeConfig.type==2">
							<text class="placeholder"
								v-if="!copyerStr(nodeConfig)">请选择{{placeholderList[nodeConfig.type]}}</text>
							{{copyerStr(nodeConfig)}}
						</view>
						<text class="anticon anticon-right arrow"></text>
					</view>
					<view class="error_tip" v-if="isTried&&nodeConfig.error">
						<text class="anticon anticon-exclamation-circle" style="color: rgb(242, 86, 67);"></text>
					</view>
				</view>
			</view>
			<mAddNode :childNodeP.sync="nodeConfig.childNode"></mAddNode>
		</view>

		<!-- 下拉选弹层 -->
		<m-node-warp v-if="nodeConfig.childNode && nodeConfig.childNode" :nodeConfig.sync="nodeConfig.childNode"
			:tableId="tableId" :isTried.sync="isTried" :directorMaxLevel="directorMaxLevel"></m-node-warp>




	</view>
</template>

<script>
	import mAddNode from '@/uni_modules/mc-ui/components/m-node-warp/compontent/m-addNode/m-addNode.vue';
	// import props from './props.js'
	export default {
		name: "m-node-warp",
		// mixins: [props],
		props: ["nodeConfig", "flowPermission", "directorMaxLevel", "isTried", "tableId"],
		components: {
			mAddNode
		},
		data() {
			return {
				placeholderList: ["发起人", "审核人", "抄送人"],
				isInputList: [],
				isInput: false,
				promoterVisible: false,
				promoterDrawer: false,
				departments: {},
				checkedDepartmentList: [],
				checkedEmployessList: [],
				promoterSearchName: "",
				flowPermission1: this.flowPermission,
				approverDrawer: false,
				approverVisible: false,
				approverRoleVisible: false,
				approverConfig: {},
				approverEmplyessList: [],
				approverSearchName: "",
				roles: [],
				roleList: [],
				approverRoleSearchName: "",
				copyerDrawer: false,
				copyerVisible: false,
				copyerConfig: {},
				copyerSearchName: "",
				activeName: "1",
				copyerEmployessList: [],
				copyerRoleList: [],
				ccSelfSelectFlag: [],
				conditionDrawer: false,
				conditionVisible: false,
				conditionConfig: {},
				conditionsConfig: {
					conditionNodes: [],
				},
				bPriorityLevel: "",
				conditions: [],
				conditionList: [],
				conditionRoleVisible: false,
				conditionRoleSearchName: "",
				conditionDepartmentList: [],
				conditionEmployessList: [],
				conditionRoleList: [],
			};
		},
		mounted() {
			let that = this;
			if (this.nodeConfig.type == 1) {
				this.nodeConfig.error = !this.setApproverStr(this.nodeConfig)
			} else if (this.nodeConfig.type == 2) {
				this.nodeConfig.error = !this.copyerStr(this.nodeConfig)
			} else if (this.nodeConfig.type == 4) {
				for (var i = 0; i < this.nodeConfig.conditionNodes.length; i++) {
					this.nodeConfig.conditionNodes[i].error = this.conditionStr(this.nodeConfig.conditionNodes[i], i) ==
						"请设置条件" && i != this.nodeConfig.conditionNodes.length - 1
				}
			}


			// 监听弹层数据回写
			uni.$on('gitCellCardInfo' + this.nodeConfig.zIndex, function(ret) {

				let typeName = ret.data.option.typeName
				if (typeName == '发起人') {
					const {
						// option: {
						// 	childDepartments,
						// 	employees
						// },
						flowPermission
					} = ret.data;

					that.$emit("update:flowPermission", flowPermission);

				} else if (typeName == '审核人') {
					const {
						approverConfig
					} = ret.data;
					// console.log(approverConfig);
					that.$emit("update:nodeConfig", approverConfig);
				} else if (typeName == '抄送人') {
					const {
						copyerConfig
					} = ret.data;
					// console.log(copyerConfig);
					that.$emit("update:nodeConfig", copyerConfig);
				}
			})
		},
		methods: {
			selectData(num, str) { // 映射层级主管选项
				let arr = [];
				for (let i = 1; i <= num; i++) {
					let text = '';

					if (str == '最高') {
						text = i == 1 ? '最高层级主管' : '第' + i + '层级主管'
					} else if (str == '直接') {
						text = i == 1 ? '直接主管' : '第' + i + '级主管'
					}

					arr.push({
						text: text,
						value: i,
					})
				};
				return arr;
			},
			clickEvent(index) {
				if (index || index === 0) {
					this.$set(this.isInputList, index, true)
				} else {
					this.isInput = true;
				}
			},
			blurEvent(index) {
				if (index || index === 0) {
					this.$set(this.isInputList, index, false)
					this.nodeConfig.conditionNodes[index].nodeName = this.nodeConfig.conditionNodes[index].nodeName ? this
						.nodeConfig.conditionNodes[index].nodeName : "条件"
				} else {
					this.isInput = false;
					this.nodeConfig.nodeName = this.nodeConfig.nodeName ? this.nodeConfig.nodeName : this.placeholderList[
						this.nodeConfig.type]
				}
			},
			conditionStr(item, index) {
				var {
					conditionList,
					nodeUserList
				} = item;
				if (conditionList.length == 0) {
					return (index == this.nodeConfig.conditionNodes.length - 1) && this.nodeConfig.conditionNodes[0]
						.conditionList.length != 0 ? '其他条件进入此流程' : '请设置条件'
				} else {
					let str = ""
					for (var i = 0; i < conditionList.length; i++) {
						var {
							columnId,
							columnType,
							showType,
							showName,
							optType,
							zdy1,
							opt1,
							zdy2,
							opt2,
							fixedDownBoxValue
						} = conditionList[i];
						if (columnId == 0) {
							if (nodeUserList.length != 0) {
								str += '发起人属于：'
								str += nodeUserList.map(item => {
									return item.name
								}).join("或") + " 并且 "
							}
						}
						if (columnType == "String" && showType == "3") {
							if (zdy1) {
								str += showName + '属于：' + this.dealStr(zdy1, JSON.parse(fixedDownBoxValue)) + " 并且 "
							}
						}
						if (columnType == "Double") {
							if (optType != 6 && zdy1) {
								var optTypeStr = ["", "<", ">", "≤", "=", "≥"][optType]
								str += `${showName} ${optTypeStr} ${zdy1} 并且 `
							} else if (optType == 6 && zdy1 && zdy2) {
								str += `${zdy1} ${opt1} ${showName} ${opt2} ${zdy2} 并且 `
							}
						}
					}
					return str ? str.substring(0, str.length - 4) : '请设置条件'
				}
			},
			dealStr(str, obj) {
				let arr = [];
				let list = str.split(",");
				for (var elem in obj) {
					list.map(item => {
						if (item == elem) {
							arr.push(obj[elem].value)
						}
					})
				}
				return arr.join("或")
			},
			addConditionRole() {
				this.conditionRoleSearchName = "";
				this.conditionRoleVisible = true;
				this.activeName = "1";
				this.getDepartmentList();
				this.conditionDepartmentList = [];
				this.conditionEmployessList = [];
				this.conditionRoleList = [];
				for (var i = 0; i < this.conditionConfig.nodeUserList.length; i++) {
					var {
						type,
						name,
						targetId
					} = this.conditionConfig.nodeUserList[i];
					if (type == 1) {
						this.conditionEmployessList.push({
							employeeName: name,
							id: targetId
						});
					} else if (type == 2) {
						this.conditionRoleList.push({
							roleName: name,
							roleId: targetId
						});
					} else if (type == 3) {
						this.conditionDepartmentList.push({
							departmentName: name,
							id: targetId
						});
					}
				}
			},
			sureConditionRole() {
				this.conditionConfig.nodeUserList = [];
				this.conditionRoleList.map(item => {
					this.conditionConfig.nodeUserList.push({
						type: 2,
						targetId: item.roleId,
						name: item.roleName
					})
				});
				this.conditionDepartmentList.map(item => {
					this.conditionConfig.nodeUserList.push({
						type: 3,
						targetId: item.id,
						name: item.departmentName
					})
				});
				this.conditionEmployessList.map(item => {
					this.conditionConfig.nodeUserList.push({
						type: 1,
						targetId: item.id,
						name: item.employeeName
					})
				});
				this.conditionRoleVisible = false;
			},
			addCondition() {
				this.conditionList = [];
				this.conditionVisible = true;
				this.$axios.get(`${process.env.BASE_URL}conditions.json?tableId=${this.tableId}`).then(res => {
					this.conditions = res.data;
					if (this.conditionConfig.conditionList) {
						for (var i = 0; i < this.conditionConfig.conditionList.length; i++) {
							var {
								columnId
							} = this.conditionConfig.conditionList[i]
							if (columnId == 0) {
								this.conditionList.push({
									columnId: 0
								})
							} else {
								this.conditionList.push(this.conditions.filter(item => {
									return item.columnId == columnId;
								})[0])
							}
						}
					}
				})
			},
			changeOptType(item) {
				if (item.optType == 1) {
					item.zdy1 = 2;
				} else {
					item.zdy1 = 1;
					item.zdy2 = 2;
				}
			},
			sureCondition() {
				//1.弹窗有，外面无+
				//2.弹窗有，外面有不变
				for (var i = 0; i < this.conditionList.length; i++) {
					var {
						columnId,
						showName,
						columnName,
						showType,
						columnName,
						columnType,
						fixedDownBoxValue
					} = this.conditionList[i];
					if (this.toggleClass(this.conditionConfig.conditionList, this.conditionList[i], "columnId")) {
						continue;
					}
					if (columnId == 0) {
						this.conditionConfig.nodeUserList == [];
						this.conditionConfig.conditionList.push({
							"type": 1,
							"columnId": columnId,
							"showName": '发起人'
						});
					} else {
						if (columnType == "Double") {
							this.conditionConfig.conditionList.push({
								"showType": showType,
								"columnId": columnId,
								"type": 2,
								"showName": showName,
								"optType": "1",
								"zdy1": "2",
								"opt1": "<",
								"zdy2": "",
								"opt2": "<",
								"columnDbname": columnName,
								"columnType": columnType,
							})
						} else if (columnType == "String" && showType == "3") {
							this.conditionConfig.conditionList.push({
								"showType": showType,
								"columnId": columnId,
								"type": 2,
								"showName": showName,
								"zdy1": "",
								"columnDbname": columnName,
								"columnType": columnType,
								"fixedDownBoxValue": fixedDownBoxValue
							})
						}
					}
				}
				////3.弹窗无，外面有-
				for (var i = this.conditionConfig.conditionList.length - 1; i >= 0; i--) {
					if (!this.toggleClass(this.conditionList, this.conditionConfig.conditionList[i], "columnId")) {
						this.conditionConfig.conditionList.splice(i, 1);
					}
				}
				this.conditionConfig.conditionList.sort(function(a, b) {
					return a.columnId - b.columnId;
				});
				this.conditionVisible = false;
			},
			saveCondition() {
				this.conditionDrawer = false;
				var a = this.conditionsConfig.conditionNodes.splice(this.bPriorityLevel - 1, 1) //截取旧下标
				this.conditionsConfig.conditionNodes.splice(this.conditionConfig.priorityLevel - 1, 0, a[0]) //填充新下标
				this.conditionsConfig.conditionNodes.map((item, index) => {
					item.priorityLevel = index + 1
				});
				for (var i = 0; i < this.conditionsConfig.conditionNodes.length; i++) {
					this.conditionsConfig.conditionNodes[i].error = this.conditionStr(this.conditionsConfig.conditionNodes[
						i], i) == "请设置条件" && i != this.conditionsConfig.conditionNodes.length - 1
				}
				this.$emit("update:nodeConfig", this.conditionsConfig);
			},
			getDebounceData(event, type = 1) {
				this.$func.debounce(function() {
					if (event.target.value) {
						if (type == 1) {
							this.departments.childDepartments = [];
							this.$axios.get(
								`${process.env.BASE_URL}employees.json?searchName=${event.target.value}&pageNum=1&pageSize=30`
							).then(res => {
								this.departments.employees = res.data.list
							})
						} else {
							this.$axios.get(
								`${process.env.BASE_URL}roles.json?searchName=${event.target.value}&pageNum=1&pageSize=30`
							).then(res => {
								this.roles = res.data.list
							})
						}
					} else {
						type == 1 ? this.getDepartmentList() : this.getRoleList();
					}
				}.bind(this))()
			},
			handleClick() {
				this.copyerSearchName = "";
				this.conditionRoleSearchName = "";
				if (this.activeName == 1) {
					this.getDepartmentList();
				} else {
					this.getRoleList();
				}
			},
			addCopyer() {
				this.copyerSearchName = "";
				this.copyerVisible = true;
				this.activeName = "1";
				this.getDepartmentList();
				this.copyerEmployessList = [];
				this.copyerRoleList = [];
				for (var i = 0; i < this.copyerConfig.nodeUserList.length; i++) {
					var {
						type,
						name,
						targetId
					} = this.copyerConfig.nodeUserList[i];
					if (type == 1) {
						this.copyerEmployessList.push({
							employeeName: name,
							id: targetId
						});
					} else if (type == 2) {
						this.copyerRoleList.push({
							roleName: name,
							roleId: targetId
						});
					}
				}
			},
			sureCopyer() {
				this.copyerConfig.nodeUserList = [];
				this.copyerEmployessList.map(item => {
					this.copyerConfig.nodeUserList.push({
						type: 1,
						targetId: item.id,
						name: item.employeeName
					})
				});
				this.copyerRoleList.map(item => {
					this.copyerConfig.nodeUserList.push({
						type: 2,
						targetId: item.roleId,
						name: item.roleName
					})
				});
				this.copyerVisible = false;
			},
			saveCopyer() {
				this.copyerConfig.ccSelfSelectFlag = this.ccSelfSelectFlag.length == 0 ? 0 : 1;
				this.copyerConfig.error = !this.copyerStr(this.copyerConfig);
				this.$emit("update:nodeConfig", this.copyerConfig);
				this.copyerDrawer = false;
			},
			copyerStr(nodeConfig) {
				if (nodeConfig.nodeUserList.length != 0) {
					return this.arrToStr(nodeConfig.nodeUserList)
				} else {
					if (nodeConfig.ccSelfSelectFlag == 1) {
						return "发起人自选"
					}
				}
			},
			changeRange(val) {
				this.approverConfig.nodeUserList = [];
			},
			changeType(val) {
				console.log(this.approverConfig);
				console.log(val);
				this.approverConfig.nodeUserList = [];
				this.approverConfig.examineMode = 1;
				this.approverConfig.noHanderAction = 2;
				if (val == 2) {
					this.approverConfig.directorLevel = 1;
				} else if (val == 4) {
					this.approverConfig.selectMode = 2;
					this.approverConfig.selectRange = 1;
				} else if (val == 7) {
					this.approverConfig.examineEndDirectorLevel = 1
				}
				console.log(this.approverConfig.settype);
			},
			addApprover() {
				this.approverVisible = true;
				this.approverSearchName = "";
				this.getDepartmentList();
				this.approverEmplyessList = [];
				for (var i = 0; i < this.approverConfig.nodeUserList.length; i++) {
					var {
						name,
						targetId
					} = this.approverConfig.nodeUserList[i];
					this.approverEmplyessList.push({
						employeeName: name,
						id: targetId
					});
				}
			},
			addRoleApprover() {
				this.approverRoleVisible = true;
				this.approverRoleSearchName = "";
				this.getRoleList();
				this.roleList = [];
				for (var i = 0; i < this.approverConfig.nodeUserList.length; i++) {
					var {
						name,
						targetId
					} = this.approverConfig.nodeUserList[i];
					this.roleList.push({
						roleName: name,
						roleId: targetId
					});
				}
			},
			sureApprover() {
				this.approverConfig.nodeUserList = [];
				if (this.approverConfig.settype == 1 || (this.approverConfig.settype == 4 && this.approverConfig
						.selectRange == 2)) {
					this.approverEmplyessList.map(item => {
						this.approverConfig.nodeUserList.push({
							type: 1,
							targetId: item.id,
							name: item.employeeName
						})
					});
					this.approverVisible = false;
				} else if (this.approverConfig.settype == 4 && this.approverConfig.selectRange == 3) {
					this.roleList.map(item => {
						this.approverConfig.nodeUserList.push({
							type: 2,
							targetId: item.roleId,
							name: item.roleName
						})
					});
					this.approverRoleVisible = false;
				}
			},
			setApproverStr(nodeConfig) {
				if (nodeConfig.settype == 1) {
					if (nodeConfig.nodeUserList.length == 1) {
						return nodeConfig.nodeUserList[0].name
					} else if (nodeConfig.nodeUserList.length > 1) {
						if (nodeConfig.examineMode == 1) {
							return this.arrToStr(nodeConfig.nodeUserList)
						} else if (nodeConfig.examineMode == 2) {
							return nodeConfig.nodeUserList.length + "人会签"
						}
					}
				} else if (nodeConfig.settype == 2) {
					let level = nodeConfig.directorLevel == 1 ? '直接主管' : '第' + nodeConfig.directorLevel + '级主管'
					if (nodeConfig.examineMode == 1) {
						return level
					} else if (nodeConfig.examineMode == 2) {
						return level + "会签"
					}
				} else if (nodeConfig.settype == 4) {
					if (nodeConfig.selectRange == 1) {
						return "发起人自选"
					} else {
						if (nodeConfig.nodeUserList.length > 0) {
							if (nodeConfig.selectRange == 2) {
								return "发起人自选"
							} else {
								return '发起人从' + nodeConfig.nodeUserList[0].name + '中自选'
							}
						} else {
							return "";
						}
					}
				} else if (nodeConfig.settype == 5) {
					return "发起人自己"
				} else if (nodeConfig.settype == 7) {
					return '从直接主管到通讯录中级别最高的第' + nodeConfig.examineEndDirectorLevel + '个层级主管'
				}
			},
			saveApprover() {
				this.approverConfig.error = !this.setApproverStr(this.approverConfig)
				this.$emit("update:nodeConfig", this.approverConfig);
				this.approverDrawer = false;
			},
			addPromoter() {
				this.promoterVisible = true;
				this.getDepartmentList();
				this.promoterSearchName = "";
				this.checkedEmployessList = [];
				this.checkedDepartmentList = [];
				for (var i = 0; i < this.flowPermission1.length; i++) {
					var {
						type,
						name,
						targetId
					} = this.flowPermission1[i];
					if (type == 1) {
						this.checkedEmployessList.push({
							employeeName: name,
							id: targetId
						});
					} else if (type == 3) {
						this.checkedDepartmentList.push({
							departmentName: name,
							id: targetId
						});
					}
				}
			},
			surePromoter() {
				this.flowPermission1 = [];
				this.checkedDepartmentList.map(item => {
					this.flowPermission1.push({
						type: 3,
						targetId: item.id,
						name: item.departmentName
					})
				});
				this.checkedEmployessList.map(item => {
					this.flowPermission1.push({
						type: 1,
						targetId: item.id,
						name: item.employeeName
					})
				});
				this.promoterVisible = false;
			},
			savePromoter() {
				this.$emit("update:flowPermission", this.flowPermission1);
				this.promoterDrawer = false;
			},
			arrToStr(arr) {
				if (!uni.$m.utils.isEmpty(arr)) {
					return arr.map(item => {
						return item.name
					}).toString()
				} else {
					return '所有人'
				}
			},
			toggleStrClass(item, key) {
				let a = item.zdy1 ? item.zdy1.split(",") : []
				return a.some(item => {
					return item == key
				});
			},
			toStrChecked(item, key) {
				let a = item.zdy1 ? item.zdy1.split(",") : []
				var isIncludes = this.toggleStrClass(item, key);
				if (!isIncludes) {
					a.push(key)
					item.zdy1 = a.toString()
				} else {
					this.removeStrEle(item, key);
				}
			},
			removeStrEle(item, key) {
				let a = item.zdy1 ? item.zdy1.split(",") : []
				var includesIndex;
				a.map((item, index) => {
					if (item == key) {
						includesIndex = index
					}
				});
				a.splice(includesIndex, 1);
				item.zdy1 = a.toString()
			},
			toggleClass(arr, elem, key = 'id') {
				return arr.some(item => {
					return item[key] == elem[key]
				});
			},
			toChecked(arr, elem, key = 'id') {
				var isIncludes = this.toggleClass(arr, elem, key);
				!isIncludes ? arr.push(elem) : this.removeEle(arr, elem, key);
			},
			removeEle(arr, elem, key = 'id') {
				var includesIndex;
				arr.map((item, index) => {
					if (item[key] == elem[key]) {
						includesIndex = index
					}
				});
				arr.splice(includesIndex, 1);
			},
			getRoleList() {
				var that = this;

				var sql = "select * from [SYS_Role]";
				this.Request.requestByUrl("/SQLData/GetDataBySql", {
					// programId: localStorage.getItem("programId"),
					programId: 0,
					sql: sql
				}, function(data) {
					console.log(data);
					data = data.data;
					let role = {
						"navigatepageNums": [],
						"startRow": "1",
						"hasNextPage": "false",
						"prePage": "0",
						"nextPage": "0",
						"endRow": data.ds.length.toString(),
						"pageSize": "0",
						"list": []
					}


					for (var i = 0; i < data.ds.length; i++) {
						role.list.push({
							"code": data.ds[i].RoleCode.toString(),
							"roleId": data.ds[i].RoleID.toString(),
							"scope": "1",
							"roleName": data.ds[i].RoleName.toString(),
							"description": data.ds[i].RoleName.toString(),
							"status": "1"
						});
					}
					that.roles = role.list;
				}, "json");

				// this.$axios.get(`${process.env.BASE_URL}roles.json`).then(res => {
				//     this.roles = res.data.list;
				// })
			},
			getDepartmentList(parentId = 0) {
				var that = this;
				console.log(parentId);
				var sql = "select * from Hr_Class where ClassCode!='LZM' and UpID=" + parentId;
				sql += " select a.* from SYS_User a,Hr_Employee b\
                    where a.EmplID = b.EmplID and b.ClassID=   " + parentId;
				this.Request.requestByUrl("/SQLData/GetDataBySql", {
					// programId: localStorage.getItem("programId"),
					programId: 0,
					sql: sql
				}, function(data) {
					console.log(data);
					// data = data.data;
					that.departments = {};
					let childDepartments = [];
					for (var i = 0; i < data.ds.length; i++) {
						childDepartments.push({
							"departmentKey": data.ds[i].ClassName,
							"departmentName": data.ds[i].ClassName,
							"id": data.ds[i].ClassID.toString(),
							"parentId": data.ds[i].UpID.toString(),
							"departmentNames": data.ds[i].ClassName
						});
					}
					let employees = [];
					for (var i = 0; i < data.ds1.length; i++) {
						employees.push({
							"id": data.ds1[i].UserID.toString(),
							"employeeName": data.ds1[i].UserName,
							"isLeave": "0",
							"open": "false"
						})
					}
					that.departments.childDepartments = childDepartments;
					that.departments.employees = employees;
				}, "json");




				// this.$axios.get(`${process.env.BASE_URL}departments.json?parentId=${parentId}`).then(res => {
				//     this.departments = res.data;
				// })
			},
			delNode() {
				this.$emit("update:nodeConfig", this.nodeConfig.childNode);
			},
			addTerm() {
				let len = this.nodeConfig.conditionNodes.length + 1
				this.nodeConfig.conditionNodes.push({
					"nodeName": "条件" + len,
					"type": 3,
					"priorityLevel": len,
					"conditionList": [],
					"nodeUserList": [],
					"childNode": null
				});
				for (var i = 0; i < this.nodeConfig.conditionNodes.length; i++) {
					this.nodeConfig.conditionNodes[i].error = this.conditionStr(this.nodeConfig.conditionNodes[i], i) ==
						"请设置条件" && i != this.nodeConfig.conditionNodes.length - 1
				}
				this.$emit("update:nodeConfig", this.nodeConfig);
			},
			delTerm(index) {
				this.nodeConfig.conditionNodes.splice(index, 1)
				for (var i = 0; i < this.nodeConfig.conditionNodes.length; i++) {
					this.nodeConfig.conditionNodes[i].error = this.conditionStr(this.nodeConfig.conditionNodes[i], i) ==
						"请设置条件" && i != this.nodeConfig.conditionNodes.length - 1
				}
				this.$emit("update:nodeConfig", this.nodeConfig);
				if (this.nodeConfig.conditionNodes.length == 1) {
					if (this.nodeConfig.childNode) {
						if (this.nodeConfig.conditionNodes[0].childNode) {
							this.reData(this.nodeConfig.conditionNodes[0].childNode, this.nodeConfig.childNode)
						} else {
							this.nodeConfig.conditionNodes[0].childNode = this.nodeConfig.childNode
						}
					}
					this.$emit("update:nodeConfig", this.nodeConfig.conditionNodes[0].childNode);
				}
			},
			reData(data, addData) {
				if (!data.childNode) {
					data.childNode = addData
				} else {
					this.reData(data.childNode, addData)
				}
			},
			setPerson(priorityLevel) {
				var {
					type
				} = this.nodeConfig;
				if (type == 0) { // 发起人

					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'BaseScreenParm',
						data: JSON.parse(JSON.stringify(this.flowPermission))
					});
					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'nodewarpIndex',
						data: this.nodeConfig.zIndex
					});

					uni.navigateTo({
						url: '/uni_modules/mc-ui/components/m-node-warp/compontentPage/initiator-code/initiator-code' +
							'?typeName=发起人&str=成员'
					})
				} else if (type == 1) { // 审核人

					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'BaseScreenParm',
						data: JSON.parse(JSON.stringify(this.nodeConfig))
					});
					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'nodewarpIndex',
						data: this.nodeConfig.zIndex
					});

					uni.navigateTo({
						url: '/uni_modules/mc-ui/components/m-node-warp/compontentPage/approver-code/approver-code' +
							'?typeName=审核人'
					})
				} else if (type == 2) { // 抄送人

					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'BaseScreenParm',
						data: JSON.parse(JSON.stringify(this.nodeConfig))
					});
					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'nodewarpIndex',
						data: this.nodeConfig.zIndex
					});

					uni.navigateTo({
						url: '/uni_modules/mc-ui/components/m-node-warp/compontentPage/ccRecipients-code/ccRecipients-code' +
							'?typeName=抄送人'
					})
				} else {
					// this.conditionDrawer = true
					// this.bPriorityLevel = priorityLevel;
					// this.conditionsConfig = JSON.parse(JSON.stringify(this.nodeConfig))
					// this.conditionConfig = this.conditionsConfig.conditionNodes[priorityLevel - 1]
				}
			},
			arrTransfer(index, type = 1) { //向左-1,向右1
				this.nodeConfig.conditionNodes[index] = this.nodeConfig.conditionNodes.splice(index + type, 1,
					this
					.nodeConfig.conditionNodes[index])[0];
				this.nodeConfig.conditionNodes.map((item, index) => {
					item.priorityLevel = index + 1
				})
				for (var i = 0; i < this.nodeConfig.conditionNodes.length; i++) {
					this.nodeConfig.conditionNodes[i].error = this.conditionStr(this.nodeConfig.conditionNodes[
							i], i) ==
						"请设置条件" && i != this.nodeConfig.conditionNodes.length - 1
				}
				this.$emit("update:nodeConfig", this.nodeConfig);
			}
		}
	}
</script>

<style lang="scss">
	@import url("../../static/css/override-element-ui.css");
	@import url("../../static/css/workflow.css");

	.error_tip {
		position: absolute;
		top: 0px;
		right: 0px;
		transform: translate(150%, 0px);
		font-size: 24px;
	}

	.add-node-popover-body {
		display: flex;
	}

	.promoter_content {
		padding: 0 20px;
	}

	.condition_content button,
	.copyer_content button,
	.approver_self_select button,
	.promoter_content button,
	.approver_content button {
		margin-bottom: 20px;
	}

	.promoter_content p {
		padding: 18px 0;
		font-size: 14px;
		line-height: 20px;
		color: #000000;
	}

	.promoter_person .u-popup__body {
		padding: 10px 20px 14px 20px;
	}

	.person_body {
		border: 1px solid #f5f5f5;
		height: 400px;
	}

	.person_tree {
		padding: 10px 12px 0 8px;
		width: 280px;
		height: 100%;
		border-right: 1px solid #f5f5f5;
	}

	.person_tree input {
		padding-left: 22px;
		width: 210px;
		height: 30px;
		font-size: 12px;
		border-radius: 2px;
		border: 1px solid #d5dadf;
		background: url(@/static/assets/image/nodeWarp/list_search.png) no-repeat 10px center;
		background-size: 14px 14px;
		margin-bottom: 14px;
	}

	.tree_nav text {
		display: inline-block;
		padding-right: 10px;
		margin-right: 5px;
		max-width: 6em;
		color: #38adff;
		font-size: 12px;
		cursor: pointer;
		background: url(@/static/assets/image/nodeWarp/jiaojiao.png) no-repeat right center;
	}

	.tree_nav text:last-of-type {
		background: none;
	}

	.person_tree ul,
	.has_selected ul {
		height: 334px;
		overflow-y: auto;
	}

	.person_tree li {
		padding: 5px 0;
	}

	.person_tree li i {
		float: right;
		padding-left: 24px;
		padding-right: 10px;
		color: #3195f8;
		font-size: 12px;
		cursor: pointer;
		background: url(@/static/assets/image/nodeWarp/next_level_active.png) no-repeat 10px center;
		border-left: 1px solid rgb(238, 238, 238);
	}

	.person_tree li a.active+i {
		color: rgb(197, 197, 197);
		background-image: url(@/static/assets/image/nodeWarp/next_level.png);
		pointer-events: none;
	}

	.person_tree image {
		width: 14px;
		vertical-align: middle;
		margin-right: 5px;
	}

	.has_selected {
		width: 276px;
		height: 100%;
		font-size: 12px;
	}

	.has_selected ul {
		height: 370px;
	}

	.has_selected p {
		padding-left: 19px;
		padding-right: 20px;
		line-height: 37px;
		border-bottom: 1px solid #f2f2f2;
	}

	.has_selected p a {
		float: right;
	}

	.has_selected ul li {
		margin: 11px 26px 13px 19px;
		line-height: 17px;
	}

	.has_selected li text {
		vertical-align: middle;
	}

	.has_selected li image:first-of-type {
		width: 14px;
		vertical-align: middle;
		margin-right: 5px;
	}

	.has_selected li image:last-of-type {
		float: right;
		margin-top: 2px;
		width: 14px;
	}

	el-radio-group {
		padding: 20px 0;
	}

	.approver_content {
		padding-bottom: 10px;
		border-bottom: 1px solid #f2f2f2;
	}

	.approver_content .el-radio,
	.approver_some .el-radio,
	.approver_self_select .el-radio {
		width: 27%;
		margin-bottom: 20px;
	}

	.copyer_content .el-checkbox {
		margin-bottom: 20px;
	}

	.el-checkbox__label {
		font-size: 12px;
	}

	.condition_content,
	.copyer_content,
	.approver_self_select,
	.approver_manager,
	.approver_content,
	.approver_some {
		padding: 20px 20px 0;
	}

	.approver_manager p:first-of-type,
	.approver_some p {
		line-height: 19px;
		font-size: 14px;
		margin-bottom: 14px;
	}

	.approver_manager p {
		line-height: 32px;
	}

	.approver_manager select {
		width: 420px;
		height: 32px;
		background: rgba(255, 255, 255, 1);
		border-radius: 4px;
		border: 1px solid rgba(217, 217, 217, 1);
	}

	.approver_manager p.tip {
		margin: 10px 0 22px 0;
		font-size: 12px;
		line-height: 16px;
		color: #f8642d;
	}

	.approver_self {
		padding: 28px 20px;
	}

	.selected_list {
		margin-bottom: 20px;
		line-height: 30px;
	}

	.selected_list text {
		margin-right: 10px;
		padding: 3px 6px 3px 9px;
		line-height: 12px;
		white-space: nowrap;
		border-radius: 2px;
		border: 1px solid rgba(220, 220, 220, 1);
	}

	.selected_list image {
		margin-left: 5px;
		width: 7px;
		height: 7px;
		cursor: pointer;
	}

	.approver_self_select h3 {
		margin: 5px 0 20px;
		font-size: 14px;
		font-weight: bold;
		line-height: 19px;
	}

	.condition_copyer .u-popup__body select {
		position: absolute;
		top: 11px;
		right: 30px;
		width: 100px;
		height: 32px;
		background: rgba(255, 255, 255, 1);
		border-radius: 4px;
		border: 1px solid rgba(217, 217, 217, 1);
	}

	.condition_content p.tip {
		margin: 20px 0;
		width: 510px;
		text-indent: 17px;
		line-height: 45px;
		background: rgba(241, 249, 255, 1);
		border: 1px solid rgba(64, 163, 247, 1);
		color: #46a6fe;
		font-size: 14px;
	}

	.condition_content ul {
		max-height: 500px;
		overflow-y: scroll;
		margin-bottom: 20px;
	}

	.condition_content li>text {
		float: left;
		margin-right: 8px;
		width: 70px;
		line-height: 32px;
		text-align: right;
	}

	.condition_content li>view {
		display: inline-block;
		width: 370px;
	}

	.condition_content li:not(:last-child)>view>p {
		margin-bottom: 20px;
	}

	.condition_content li>view>p:not(:last-child) {
		margin-bottom: 10px;
	}

	.condition_content li>a {
		float: right;
		margin-right: 10px;
		margin-top: 7px;
	}

	.condition_content li select,
	.condition_content li input {
		width: 100%;
		height: 32px;
		background: rgba(255, 255, 255, 1);
		border-radius: 4px;
		border: 1px solid rgba(217, 217, 217, 1);
	}

	.condition_content li select+input {
		width: 260px;
	}

	.condition_content li select {
		margin-right: 10px;
		width: 100px;
	}

	.condition_content li p.selected_list {
		padding-left: 10px;
		border-radius: 4px;
		min-height: 32px;
		border: 1px solid rgba(217, 217, 217, 1);
	}

	.condition_content li p.check_box {
		line-height: 32px;
	}

	.condition_list .u-popup__body {
		padding: 16px 26px;
	}

	.condition_list p {
		color: #666666;
		margin-bottom: 10px;
	}

	.condition_list p.check_box {
		margin-bottom: 0;
		line-height: 36px;
	}
</style>